from datetime import datetime

def get_current_time():
    return datetime.now().strftime('%Y-%m-%d %H:%M:%S %p')

def get_categories(user):
    category_map = {}
    for post in user.posts:
        for tag in post.tags:
            if category_map.has_key(tag.name):
                category_map[tag.name] += 1
            else:
                category_map[tag.name] = 1
    length = len(category_map)
    category_sort = sorted(category_map.iteritems(), key = lambda asd:asd[1], reverse=True)
    if length > 8:
        length = 8
    categorys_left = []
    categorys_right = []
    for i in range(length):
        if i % 2 == 0:
            categorys_left.append(category_sort[i])
        else:
            categorys_right.append(category_sort[i])

    return (categorys_left, categorys_right)
